import {request} from '../../utils/http'

Page({
  data: {
    id:'',
    status:70,
    isLoadPlugin: false,
    sign_order_type:null,
    smid:'',
    outOrderNo:'',
    order:{
      id:''
    }
  },
  onLoad(query:any) {
    // 页面加载
    //console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
    console.log(query, '页面参数')
    request("/shop/smid", "get").then((res) => {
      if (res.code == 200) {
        this.setData({
          smid: res.data.smid,
        });
      }
    });
    this.setData({
      id: query.id || 0,
      outOrderNo:query.outOrderNo || ''
    });
    this.fetch(query.id || 0);
  },
  fetch(id) {
    let params = {}
    if (this.data.outOrderNo) {
      params['outOrderNo'] = this.data.outOrderNo
    }
    request("/order/" + id, "get", params).then((res) => {

      this.setData({
        order: res.data,
      });
    
    });
  },

  goOrder(){
    my.navigateTo({ url: '../orderDetail/index?id=' + this.data.order.id})
  },
  goPortal(){
    my.switchTab({
      url:'/pages/index/index'
    })
  }
});
